package com.gy.niuer.controller;

import com.gy.niuer.domain.Patient;
import com.gy.niuer.service.PatientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lhj
 * @create 2022/7/8 10:31
 */
@RestController
@RequestMapping("/manager")
@CrossOrigin
@Slf4j
public class ManagerController {
    @Autowired
    PatientService patientService;

    @GetMapping("/selectAllPatient")
    public List<Patient> selectAllPatient(){
        List<Patient> patients = patientService.selectAllPatient();
        return patients;
    }

    /**
     * 后台添加就诊人信息
     */
    @PostMapping("/add")
    public boolean addPatient(@RequestBody Patient patient){
        return patientService.insertPatient(patient);
    }

    @PutMapping("/del/{id}")
    public boolean delPatient(@PathVariable int id){
        boolean b = patientService.delPatient(id);
        return b;
    }

    @PutMapping("/update")
    public boolean updatePatient(@RequestBody Patient patient){
        boolean b = patientService.updateById(patient);
        return b;
    }


    @GetMapping("/delAll")
    public boolean delPatient(@RequestBody String[] delArr){
        System.out.println(delArr);
        return true;
    }
}
